﻿namespace CatClient.Message.Internals
{
    using CatClient.Message;
    using CatClient.Message.Spi;
    using System;
    using System.Runtime.InteropServices;

    public class DefaultMetric : AbstractMessage, IMetric, IMessage
    {
        private readonly IMessageManager _messageManager;

        public DefaultMetric(string type, string name, IMessageManager messageManager = null) : base(type, name, messageManager)
        {
            this._messageManager = messageManager;
        }

        public override void Complete()
        {
            base.SetCompleted(true);
            if (this._messageManager != null)
            {
                this._messageManager.Add(this);
            }
        }
    }
}

